import request from '../utils/request'
import type { ApiResponse, PageResult } from '../types/api'

export interface Prize {
  id: number
  name: string
  value: number
  description?: string
}

export interface Record {
  id: number
  userId: number
  phone: string
  prizeId: number
  prizeName: string
  prizeValue: number
  createTime: string
}

export interface RecordQuery {
  current: number
  size: number
  phone?: string
}

export const lotteryApi = {
  // 执行抽奖
  draw(phone: string): Promise<ApiResponse<Prize>> {
    return request.post('/api/lottery/draw', { phone })
  },

  // 获取抽奖记录
  getRecords(params: RecordQuery) {
    return request.get<ApiResponse<PageResult<Record>>>('/api/lottery/record/list', { params })
  }
} 